{extend name="common:frm_base" /}
{block name="content"}
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body">
            <form class="layui-form" action="{:url('bus_business/handle')}" lay-filter="component-form-group">
                <div class="layui-tab layui-tab-brief" lay-filter="component-tabs-brief">
                    <ul class="layui-tab-title">
                        <li class="layui-this">基础信息</li>
                        <li class="">认证信息</li>
                    </ul>
                    <div class="layui-tab-content">
                        <div class="layui-tab-item layui-show">
                            <div class="layui-form-item">
                                <label class="layui-form-label">车队名称</label>
                                <div class="layui-input-inline">
                                    <input type="text" value="{$info.name|default=''}" name="name" lay-verify="" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">绑定手机</label>
                                <div class="layui-input-inline">
                                    <input type="text" value="{$info.mobile|default=''}" name="mobile" lay-verify="" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">状态</label>
                                <div class="layui-input-block">
                                    <input type="radio" title="{$info->status}" checked >
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">操作</label>
                                <div class="layui-input-block">
                                    <input type="radio" name="status" value="0" title="审核不通过" {if $info->getData('status') == 0 }checked{/if} >
                                    <input type="radio" name="status" value="1" title="审核通过" {if $info->getData('status') == 1 }checked{/if} >
                                    <input type="radio" name="status" value="2" title="冻结" {if $info->getData('status') == 2 }checked{/if} >
                                </div>
                            </div>
                        </div>
                        <div class="layui-tab-item">
                            <div class="layui-form-item">
                                <label class="layui-form-label">车队规模</label>
                                <div class="layui-input-inline">
                                    <input type="text" value="{$info.info.bus_num|default=''}" name="bus_num" lay-verify="" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>
                                <div class="layui-form-mid layui-word-aux">(辆)</div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">身份证号码</label>
                                <div class="layui-input-inline">
                                    <input type="text" value="{$info.info.id_card_no|default=''}" name="id_card_no" lay-verify="" placeholder="请输入" autocomplete="off" class="layui-input">
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">身份证正面</label>
                                <div class="layui-input-block">
                                    <div class="layui-upload">
                                        <button type="button" class="layui-btn upload_icon" lay-data="{ url: '{:url('common/upload_img')}', accept: 'images', data:{src_name:'bus_business'} }">
                                            <i class="layui-icon">&#xe67c;</i>上传图片
                                        </button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            <div class="layui-upload-list">
                                                <div class="layui-row pic-list" >
                                                    <div class="layui-col-xs3">
                                                        <img src="{$info.info.id_card_front}" width="30%" class="layui-upload-img" >
                                                    </div>
                                                    <input type="hidden" class="hidden" name="id_card_front" value="" />
                                                </div>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">身份证背面</label>
                                <div class="layui-input-block">
                                    <div class="layui-upload">
                                        <button type="button" class="layui-btn upload_icon" lay-data="{ url: '{:url('common/upload_img')}', accept: 'images', data:{src_name:'bus_business'} }">
                                            <i class="layui-icon">&#xe67c;</i>上传图片
                                        </button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            <div class="layui-upload-list">
                                                <div class="layui-row pic-list" >
                                                    <div class="layui-col-xs3">
                                                        <img src="{$info.info.id_card_back}" width="30%" class="layui-upload-img" >
                                                    </div>
                                                    <input type="hidden" class="hidden" name="id_card_back" value="" />
                                                </div>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label">营业执照</label>
                                <div class="layui-input-block">
                                    <div class="layui-upload">
                                        <button type="button" class="layui-btn upload_icon" lay-data="{ url: '{:url('common/upload_img')}', accept: 'images', data:{src_name:'bus_business'} }">
                                            <i class="layui-icon">&#xe67c;</i>上传图片
                                        </button>
                                        <blockquote class="layui-elem-quote layui-quote-nm" style="margin-top: 10px;">
                                            <div class="layui-upload-list">
                                                <div class="layui-row pic-list" >
                                                    <div class="layui-col-xs3">
                                                        <img src="{$info.info.business_licence}" width="30%" class="layui-upload-img" >
                                                    </div>
                                                    <input type="hidden" class="hidden" name="business_licence" value="" />
                                                </div>
                                            </div>
                                        </blockquote>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>
                {:token()}
                <input type="hidden" value="{$act}" name="act" />
                <input type="hidden" value="{$info['id']|default=''}" name="id" />
                <input type="hidden" value="" name="icon" />
                <div class="layui-form-item layui-hide">
                    <input type="button" lay-submit lay-filter="LAY-user-front-submit" id="LAY-user-front-submit" value="确认">
                </div>
            </form>
        </div>
    </div>
</div>

<script>


    layui.config({
        base: '__LAYUIADMIN__/' //静态资源所在路径
    }).extend({
        index: 'lib/index' //主入口模块
    }).use(['index', 'table', 'upload'], function () {
        var $ = layui.$
            , form = layui.form
            , table = layui.table
            , upload = layui.upload;

        $('.pic-list').viewer();

        // form.on('submit(formSub)', function(data){
        //     console.log(data.elem) //被执行事件的元素DOM对象，一般为button对象
        //     console.log(data.form.action) //被执行提交的form对象，一般在存在form标签时才会返回
        //     console.log(data.field) //当前容器的全部表单字段，名值对形式：{name: value}
        //     var param = data.field;
        //     $.ajax({
        //         type: 'POST'
        //         ,url: data.form.action
        //         ,data: param
        //         ,dataType: 'json'
        //         ,success:function(res){
        //             if (res.code == 0){
        //                 layer.alert("提交成功");
        //             } else{
        //                 layer.alert(res.msg);
        //             }
        //         }
        //     })
        //     return false; //阻止表单跳转。如果需要表单跳转，去掉这段即可。
        // });

        upload.render({
            elem: '.upload_icon'
            ,accept: 'images'
            ,acceptMime: 'image/*,image/gif'
            ,before: function(obj){
                //预读本地文件示例，不支持ie8
                obj.preview(function(index, file, result){
                    // console.log($(this));
                    // $('#upload_icon-img').attr('src', result); //图片链接（base64）
                    // console.log($(this).parents(".layui-upload"));
                });
            }
            ,done: function(res, index, upload){
                var item = this.item;
                //如果上传失败
                if(res.code > 0){
                    $('#upload_icon-img').attr('src', " ");
                    layer.msg('上传失败');
                } else{
                    $(this.item).parents(".layui-upload").find("img").attr('src', "\\uploads\\" + res.data)
                    $(this.item).parents(".layui-upload").find(".hidden").val(res.data)
                    layer.msg('上传成功');
                }
                //上传成功
            }
            // ,error: function(){
            //     //演示失败状态，并实现重传
            //     var demoText = $('#test-upload-demoText');
            //     demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-mini demo-reload">重试</a>');
            //     demoText.find('.demo-reload').on('click', function(){
            //         uploadInst.upload();
            //     });
            // }
        });


    });

    function openImg(i) {
        layer.photos({
            photos: '.pic-list'
        });
    }
</script>
</body>
</html>
{/block}
